How to RSYNC
The RSYNC command is an easy tool used to copy files from one location to another; locally or externally. The benefit of using RSYNC over the common copy command is that RSYNC can cut down the time necessary for moving files by predetermining what is already present on the destination and only copying over what isn’t already there.
There are a number of different methods to copying files over, however each method uses the same command.
Local
rsync -Pav /path/to/source /path/to/destination
External
-
Push Method:
rsync -Pav --rsh="ssh -p [SSH_Port]" /path/to/source USER@DESTINATION:/path/to/destination/
-
Pull Method:
rsync -Pav --rsh="ssh -p [SSH_Port]" USER@SOURCE:/path/to/source /path/to/destination
Variable Legend for Above Commands:
Variable | Description |
---|---|
USER | Remote user located on remote server |
SOURCE | The file(s)/directory(ies) to be copied to another location |
DESTINATION | The destination target to copi files/directories to |
-Pav | -P Shows progress of RSYNC |
-a Archive mode (equivalent to -rlptgoD) | |
-v Verbose (give you information about what files are being transferred and a brief summary at the end) | |
--rsh | Specify the remote shell |
-p [SSH_Port] | Specify SSH port number. Replace [SSH_Port] with the actual port number. |